// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Definition of a Serverless VPC Access connector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Connector {
    /// The resource name in the format `projects/*/locations/*/connectors/*`.
    pub name: std::string::String,

    /// Name of a VPC network.
    pub network: std::string::String,

    /// The range of internal addresses that follows RFC 4632 notation.
    /// Example: `10.132.0.0/28`.
    pub ip_cidr_range: std::string::String,

    /// Output only. State of the VPC access connector.
    pub state: crate::model::connector::State,

    /// Minimum throughput of the connector in Mbps. Default and min is 200.
    pub min_throughput: i32,

    /// Maximum throughput of the connector in Mbps. Default is 300, max is 1000.
    pub max_throughput: i32,

    /// Output only. List of projects using the connector.
    pub connected_projects: std::vec::Vec<std::string::String>,

    /// The subnet in which to house the VPC Access Connector.
    pub subnet: std::option::Option<crate::model::connector::Subnet>,

    /// Machine type of VM Instance underlying connector. Default is e2-micro
    pub machine_type: std::string::String,

    /// Minimum value of instances in autoscaling group underlying the connector.
    pub min_instances: i32,

    /// Maximum value of instances in autoscaling group underlying the connector.
    pub max_instances: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Connector {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Connector::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [network][crate::model::Connector::network].
    pub fn set_network<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.network = v.into();
        self
    }

    /// Sets the value of [ip_cidr_range][crate::model::Connector::ip_cidr_range].
    pub fn set_ip_cidr_range<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.ip_cidr_range = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Connector::state].
    pub fn set_state<T: std::convert::Into<crate::model::connector::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [min_throughput][crate::model::Connector::min_throughput].
    pub fn set_min_throughput<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.min_throughput = v.into();
        self
    }

    /// Sets the value of [max_throughput][crate::model::Connector::max_throughput].
    pub fn set_max_throughput<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.max_throughput = v.into();
        self
    }

    /// Sets the value of [connected_projects][crate::model::Connector::connected_projects].
    pub fn set_connected_projects<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.connected_projects = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [subnet][crate::model::Connector::subnet].
    pub fn set_subnet<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::connector::Subnet>,
    {
        self.subnet = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [subnet][crate::model::Connector::subnet].
    pub fn set_or_clear_subnet<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::connector::Subnet>,
    {
        self.subnet = v.map(|x| x.into());
        self
    }

    /// Sets the value of [machine_type][crate::model::Connector::machine_type].
    pub fn set_machine_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.machine_type = v.into();
        self
    }

    /// Sets the value of [min_instances][crate::model::Connector::min_instances].
    pub fn set_min_instances<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.min_instances = v.into();
        self
    }

    /// Sets the value of [max_instances][crate::model::Connector::max_instances].
    pub fn set_max_instances<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.max_instances = v.into();
        self
    }
}

impl wkt::message::Message for Connector {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.Connector"
    }
}

/// Defines additional types related to [Connector].
pub mod connector {
    #[allow(unused_imports)]
    use super::*;

    /// The subnet in which to house the connector
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Subnet {
        /// Subnet name (relative, not fully qualified).
        /// E.g. if the full subnet selfLink is
        /// <https://compute.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{subnetName}>
        /// the correct input for this field would be {subnetName}
        pub name: std::string::String,

        /// Project in which the subnet exists.
        /// If not set, this project is assumed to be the project for which
        /// the connector create request was issued.
        pub project_id: std::string::String,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Subnet {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [name][crate::model::connector::Subnet::name].
        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.name = v.into();
            self
        }

        /// Sets the value of [project_id][crate::model::connector::Subnet::project_id].
        pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.project_id = v.into();
            self
        }
    }

    impl wkt::message::Message for Subnet {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.vpcaccess.v1.Connector.Subnet"
        }
    }

    /// State of a connector.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Invalid state.
        Unspecified,
        /// Connector is deployed and ready to receive traffic.
        Ready,
        /// An Insert operation is in progress. Transient condition.
        Creating,
        /// A Delete operation is in progress. Transient condition.
        Deleting,
        /// Connector is in a bad state, manual deletion recommended.
        Error,
        /// The connector is being updated.
        Updating,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Ready => std::option::Option::Some(1),
                Self::Creating => std::option::Option::Some(2),
                Self::Deleting => std::option::Option::Some(3),
                Self::Error => std::option::Option::Some(4),
                Self::Updating => std::option::Option::Some(5),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Ready => std::option::Option::Some("READY"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Error => std::option::Option::Some("ERROR"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Ready,
                2 => Self::Creating,
                3 => Self::Deleting,
                4 => Self::Error,
                5 => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "READY" => Self::Ready,
                "CREATING" => Self::Creating,
                "DELETING" => Self::Deleting,
                "ERROR" => Self::Error,
                "UPDATING" => Self::Updating,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Ready => serializer.serialize_i32(1),
                Self::Creating => serializer.serialize_i32(2),
                Self::Deleting => serializer.serialize_i32(3),
                Self::Error => serializer.serialize_i32(4),
                Self::Updating => serializer.serialize_i32(5),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.vpcaccess.v1.Connector.State",
            ))
        }
    }
}

/// Request for creating a Serverless VPC Access connector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateConnectorRequest {
    /// Required. The project and location in which the configuration should be created,
    /// specified in the format `projects/*/locations/*`.
    pub parent: std::string::String,

    /// Required. The ID to use for this connector.
    pub connector_id: std::string::String,

    /// Required. Resource to create.
    pub connector: std::option::Option<crate::model::Connector>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateConnectorRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [connector_id][crate::model::CreateConnectorRequest::connector_id].
    pub fn set_connector_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.connector_id = v.into();
        self
    }

    /// Sets the value of [connector][crate::model::CreateConnectorRequest::connector].
    pub fn set_connector<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Connector>,
    {
        self.connector = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [connector][crate::model::CreateConnectorRequest::connector].
    pub fn set_or_clear_connector<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Connector>,
    {
        self.connector = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.CreateConnectorRequest"
    }
}

/// Request for getting a Serverless VPC Access connector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetConnectorRequest {
    /// Required. Name of a Serverless VPC Access connector to get.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetConnectorRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.GetConnectorRequest"
    }
}

/// Request for listing Serverless VPC Access connectors in a location.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListConnectorsRequest {
    /// Required. The project and location from which the routes should be listed.
    pub parent: std::string::String,

    /// Maximum number of functions to return per call.
    pub page_size: i32,

    /// Continuation token.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListConnectorsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListConnectorsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListConnectorsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListConnectorsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListConnectorsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.ListConnectorsRequest"
    }
}

/// Response for listing Serverless VPC Access connectors.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListConnectorsResponse {
    /// List of Serverless VPC Access connectors.
    pub connectors: std::vec::Vec<crate::model::Connector>,

    /// Continuation token.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListConnectorsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [connectors][crate::model::ListConnectorsResponse::connectors].
    pub fn set_connectors<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Connector>,
    {
        use std::iter::Iterator;
        self.connectors = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListConnectorsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListConnectorsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.ListConnectorsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListConnectorsResponse {
    type PageItem = crate::model::Connector;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.connectors
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Request for deleting a Serverless VPC Access connector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteConnectorRequest {
    /// Required. Name of a Serverless VPC Access connector to delete.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteConnectorRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteConnectorRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteConnectorRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.DeleteConnectorRequest"
    }
}

/// Metadata for google.longrunning.Operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Output only. Method that initiated the operation e.g.
    /// google.cloud.vpcaccess.v1.Connectors.CreateConnector.
    pub method: std::string::String,

    /// Output only. Time when the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Time when the operation completed.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Name of the resource that this operation is acting on e.g.
    /// projects/my-project/locations/us-central1/connectors/v1.
    pub target: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [method][crate::model::OperationMetadata::method].
    pub fn set_method<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.method = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.vpcaccess.v1.OperationMetadata"
    }
}
